package com.pattern.structural.adaptor;

/**
 * @Description object-type adapter
 * @Author Ping
 * @Date 2022/3/28 15:57
 **/
public class EObjectAdapter implements EUsedElectricity {
    /**
     * the object to provide e-charging.
     * Here, it is the key point for object-type structural pattern.
     */
    private HomeUsedElectricity homeUsedElectricity ;

    public EObjectAdapter(HomeUsedElectricity homeUsedElectricity) {
        this.homeUsedElectricity = homeUsedElectricity;
    }

    public void setHomeUsedElectricity(HomeUsedElectricity homeUsedElectricity) {
        this.homeUsedElectricity = homeUsedElectricity;
    }

    @Override
    public void chargedWith20V() {
        // adapting logic
        System.out.println("before provided 220v") ;
        this.homeUsedElectricity.provide220V();
        System.out.println("adapting 220v to 20V") ;

    }
}
